/*
*/

#include "search.h"

#include "beam.h"
#include "display.h"
#include "event.h"
#include "timer.h"

static void Exit(u8 p){
    page=p;
    status=STT_CONTROL;
    IndicatorOn();
}

void Search(void){
    u32	ev,tim_out;

    FlashAll();
    tim_out=Timer();
    while(status==STT_SEARCH){
	ev=WaitEvent();
	switch(ev&EVN_MASK){
	case EVN_KEYPRESS:
	    tim_out=0;
	    IndicatorOn();
	    switch(GetKey(ev)){
	    case KEY___TV:
		Exit(PAG_TV);
		break;
	    case KEY_CABL:
		Exit(PAG_CBL);
		break;
	    case KEY__DVD:
		Exit(PAG_DVD);
		break;
	    case KEY__AUX:
		Exit(PAG_AUX);
	    }
	    break;
	case EVN_KEYRELEASE:
	    FlashAll();
	    tim_out=Timer();
	}
	if(TimeOut(tim_out,TIM_OUT)){
	    status=STT_CONTROL;
	    IndicatorOff();
	}
    }
}
